﻿<UserControl x:Class="Oxage.Rasterizer.Views.RasterView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:v="clr-namespace:Oxage.Rasterizer.Views"
	xmlns:m="clr-namespace:Oxage.Rasterizer.Models"
	xmlns:common="clr-namespace:Oxage.Common">
	<UserControl.Resources>
    <ResourceDictionary x:Name="theme">
      <!--
      <ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../Resources/ExpressionTheme.xaml" />
				<ResourceDictionary Source="../Resources/Styles.xaml" />
			</ResourceDictionary.MergedDictionaries>
      -->
    </ResourceDictionary>
	</UserControl.Resources>
	<UserControl.DataContext>
		<m:RasterViewModel />
	</UserControl.DataContext>
	<Grid x:Name="LayoutRoot">
		<Grid.Resources>
			<common:VisibilityConverter x:Key="VisibilityConverter" />
			<common:RadioButtonConverter x:Key="RadioButtonConverter" />
		</Grid.Resources>

		<ScrollViewer Margin="0" Padding="0" BorderThickness="0" VerticalScrollBarVisibility="Auto">
			<StackPanel MinWidth="220" CanVerticallyScroll="True" CanHorizontallyScroll="False">
				<!-- Instructions -->
				<Border Background="#595959" CornerRadius="0,3,3,3" Margin="0,0,0,2">
					<StackPanel Orientation="Vertical" Margin="6">
						<TextBlock Foreground="White">
							<Run>Print a xaml document. Visit </Run>
							<Hyperlink NavigateUri="http://xbraster.codeplex.com" FontSize="11" TargetName="_blank" Command="{Binding HyperlinkCommand}" CommandParameter="http://xbraster.codeplex.com">http://xbraster.codeplex.com</Hyperlink>
						</TextBlock>
						<Grid Visibility="{Binding HasError, Converter={StaticResource VisibilityConverter}}">
							<TextBlock Text="{Binding LastError.Message}" ToolTipService.ToolTip="{Binding LastError.StackTrace}" Foreground="Red" />
						</Grid>
					</StackPanel>
				</Border>

				<!-- Stretch -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
					<StackPanel Margin="4">
						<TextBlock Text="Alignment" Style="{DynamicResource HeaderTextStyle}" />
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<!--<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />-->
								<RowDefinition Height="0" />
								<RowDefinition Height="0" />
								<RowDefinition Height="0" />
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="65" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>

							<TextBlock Grid.Row="0" Grid.Column="0" Text="Stretch" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="0" Grid.Column="1" TabIndex="20" ItemsSource="{Binding StretchList}" SelectedItem="{Binding StretchType, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" />

							<TextBlock Grid.Row="1" Grid.Column="0" Text="Horizontal" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="1" Grid.Column="1" TabIndex="21" ItemsSource="{Binding HorizontalAlignmentList}" SelectedItem="{Binding HorizontalAlignmentType, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" />

							<TextBlock Grid.Row="2" Grid.Column="0" Text="Vertical" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="2" Grid.Column="1" TabIndex="22" ItemsSource="{Binding VerticalAlignmentList}" SelectedItem="{Binding VerticalAlignmentType, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" />

							<TextBlock Grid.Row="3" Grid.Column="0" Text="Rotation" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="3" Grid.Column="1" TabIndex="23" ItemsSource="{Binding RotationList}" SelectedItem="{Binding ImageRotation, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" Visibility="Collapsed" />

							<TextBlock Grid.Row="4" Grid.Column="0" Text="Flip h." Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="4" Grid.Column="1" TabIndex="24" ItemsSource="{Binding TrueFalse}" SelectedItem="{Binding FlipHorizontal, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" Visibility="Collapsed" />

							<TextBlock Grid.Row="5" Grid.Column="0" Text="Flip v." Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="5" Grid.Column="1" TabIndex="25" ItemsSource="{Binding TrueFalse}" SelectedItem="{Binding FlipVertical, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" Visibility="Collapsed" />
						</Grid>
					</StackPanel>
				</Border>

				<!-- Output size -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
					<StackPanel Margin="4">
						<TextBlock Text="Output size" Style="{DynamicResource HeaderTextStyle}" />
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="65" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>

							<TextBlock Grid.Row="0" Grid.Column="0" Text="Size" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="0" Grid.Column="1" TabIndex="30" ItemsSource="{Binding OutputSizeList}" SelectedItem="{Binding OutputSize, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" />

							<TextBlock Grid.Row="1" Grid.Column="0" Text="Width" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<TextBox Grid.Row="1" Grid.Column="1" TabIndex="31" Text="{Binding OutputWidth, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" />

							<TextBlock Grid.Row="2" Grid.Column="0" Text="Height" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<TextBox Grid.Row="2" Grid.Column="1" TabIndex="32" Text="{Binding OutputHeight, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" />
						</Grid>
					</StackPanel>
				</Border>

				<!-- Output format -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
					<StackPanel Margin="4">
						<TextBlock Text="Output format" Style="{DynamicResource HeaderTextStyle}" />
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="65" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>

							<TextBlock Grid.Row="0" Grid.Column="0" Text="Format" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
							<ComboBox Grid.Row="0" Grid.Column="1" TabIndex="35" ItemsSource="{Binding OutputFormatList}" SelectedItem="{Binding OutputFormat, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" />

							<TextBlock Grid.Row="1" Grid.Column="0" Text="Quality" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="{Binding OutputFormat.Extension, Converter={StaticResource VisibilityConverter}, ConverterParameter='.jpg'}" />
							<TextBox Grid.Row="1" Grid.Column="1" TabIndex="36" Text="{Binding JpegQualityLevel, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" Visibility="{Binding OutputFormat.Extension, Converter={StaticResource VisibilityConverter}, ConverterParameter='.jpg'}" />

							<TextBlock Grid.Row="2" Grid.Column="0" Text="Compress" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="{Binding OutputFormat.Extension, Converter={StaticResource VisibilityConverter}, ConverterParameter='.tif'}" />
							<ComboBox Grid.Row="2" Grid.Column="1" TabIndex="37" ItemsSource="{Binding TiffCompressionList}" SelectedItem="{Binding TiffCompression, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" common:TextBoxInstantBindingUpdate.IsEnabled="True" Visibility="{Binding OutputFormat.Extension, Converter={StaticResource VisibilityConverter}, ConverterParameter='.tif'}" />
						</Grid>
					</StackPanel>
				</Border>

				<!-- Buttons -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
					<StackPanel Margin="4" Orientation="Horizontal">
						<Button Content="Load" Command="{Binding LoadCommand}" TabIndex="40" Padding="7,4,7,4" Cursor="Hand" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" Visibility="{Binding IsStandalone, Converter={StaticResource VisibilityConverter}}" />
						<Button Content="Save" Command="{Binding SaveCommand}" TabIndex="41" Padding="7,4,7,4" Cursor="Hand" BorderThickness="2" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" IsEnabled="{Binding CanSave}" />
						<Button Content="Refresh" Command="{Binding RefreshCommand}" TabIndex="42" Padding="7,4,7,4" Cursor="Hand" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" IsEnabled="{Binding CanSave}" Visibility="{Binding IsDebug, Converter={StaticResource VisibilityConverter}}" />
					</StackPanel>
				</Border>

				<!-- Preview -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
					<StackPanel Margin="4">
						<TextBlock Text="Preview" Style="{DynamicResource HeaderTextStyle}" />
						<Border x:Name="Preview" ClipToBounds="True" Margin="0,2,0,0" MinHeight="250" CornerRadius="3">
							<Border.Background>
								<VisualBrush ViewportUnits="Absolute" Viewport="0,0,25,25" TileMode="Tile">
									<VisualBrush.Visual>
										<Grid Width="16" Height="16" Background="#FF2A2A2A">
											<Rectangle Width="8" Height="8" Fill="#FF2D2D2D" VerticalAlignment="Top" HorizontalAlignment="Left" />
											<Rectangle Width="8" Height="8" Fill="#FF2D2D2D" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
										</Grid>
									</VisualBrush.Visual>
								</VisualBrush>
							</Border.Background>

							<Viewbox Stretch="Uniform" Margin="4" MaxHeight="250">
								<Border Width="{Binding OutputWidth}" Height="{Binding OutputHeight}">
									<Border Background="{Binding PreviewBrush}">
										<!-- Preview is rendered as a container background (using VisualBrush) -->
									</Border>
								</Border>
							</Viewbox>
						</Border>
					</StackPanel>
				</Border>

				<!-- Debug -->
				<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2" Visibility="{Binding Debug, Converter={StaticResource VisibilityConverter}}">
					<Grid Margin="4">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<TextBlock Grid.Row="0" Text="Debug" Style="{DynamicResource HeaderTextStyle}" />
						<Border Grid.Row="1" ClipToBounds="True" Margin="0,2,0,0" CornerRadius="3">
							<TextBox Text="{Binding DebugMessage}" AcceptsReturn="True" TabIndex="51" Background="#444444" Foreground="White" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" />
						</Border>
					</Grid>
				</Border>

			</StackPanel>
		</ScrollViewer>

	</Grid>
</UserControl>
